<?php
$data_category = mysql_query("SELECT * FROM category")  or die(mysql_error()); 
$data_item = mysql_query("SELECT item.id, title, content, price, image, popularity, category.name, rating_max, rating_min  FROM item INNER JOIN category ON item.category = category.id LIMIT 0,8")  or die(mysql_error());

//Get lastest item
$orders = mysql_query("SELECT orders_bets.*, category.name As name  FROM orders_bets LEFT JOIN category ON orders_bets.category = category.id ORDER BY orders_bets.id DESC LIMIT 0,3")  or die(mysql_error());
?>
<script type="text/javascript" src="js/filter.js"></script>
<div class="clearafter gigs-option">
	<div class="keywordarea left">
		<span class="all"> <span> All </span>
		</span>
	</div>
	<div class="sortby right clearafter">
		<span class="active auto-sort">Auto</span> <span class="rating-sort">Rating</span>
		<span class="popularity-sort">Popularity</span> <span
			class="price-sort">Price</span>
	</div>
</div>
<div id="leftsidecontent">
	<div id="leftsidecontent_inner">		
		<div id="scrollbar1">
			<div class="scrollbar-wrap">
				<div class="scrollbar-wrap_inner">
					<div class="scrollbar">
						<div class="track">
							<div class="thumb">
								<div class="end"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="viewport">
				<div class="overview">
					<ul class="post-listing">
						<?php
						while($item = mysql_fetch_array( $data_item ))
						{
							?>
						<li class="clearafter" height="75">
							<div class="post-image">
								<a href="?p=bet&id=<?=$item["id"]?>"><img
									src="<?=$item["image"]?>" alt="post-image" title="post-image"
									width="105" height="69" /> </a>
							</div>
							<div class="post-intro">
								<h1 class="title">
									<a href="?p=bet&id=<?=$item["id"]?>"><?=$item["title"] ?> </a>
								</h1>
								<span class="author">MyUserName</span>
							</div>
							<div class="post-description">
								<?=$item["content"] ?>
							</div>
							<div class="post-action">
								<div class="price">
									$
									<?=$item["price"]?>
								</div>
								<div class="rating">
									<div class="action-thumb clearafter">
										<div class="up"></div>
										<div class="down"></div>
									</div>
									<div class="process">
										<div style="width: <?=$item["rating_max"] ?>%"></div>
									</div>									
								</div>
								<div class="category">
									<?=$item["name"] ?>
								</div>
							</div>
						</li>
						<?php
						}
						?>
						<li class="loading show display">
							<div>
								<img src="images/ajax-loader.gif" />
							</div>
						</li>
					</ul>
				</div>
			</div>			
		</div>
		<span id="gotop">
			Back up to the top
		</span>
	</div>
</div>
<div id="rightsidecontent">
	<div id="rightsidecontent_inner">		
		<div id="accordion" class="menu_accordion">
			<p class="menu_accordion_title">
				Category <span>hide</span>
			</p>
			<div class="menu_accordion_body">
				<ul class="filter-category">
					<li><label> <input type="checkbox" /><span>All</span>
					</label>
					</li>
					<?php
					while($category = mysql_fetch_array( $data_category ))
					{
						?>
					<li><label> <input type="checkbox" /><span><?=$category['name']?> </span>
					</label>
					</li>
					<? } ?>
				</ul>
			</div>
		</div>
		<div id="latest-gigs">
			<h3 class="title">Recently ordered</h3>
			<ul>
				<?php
				while($item = mysql_fetch_array( $orders ))
				{
					?>
				<li class="clearafter" id="<?=$item["id"]?>">
					<div class="left col-1">
						<a href="#"><img src="<?=$item["image"]?>" /> </a>						
					</div>
					<div class="left col-2">
						<p class="description">
							<?=substrhtml($item["title"], 0, 60) ?>
						</p>						
					</div>
					<div class="right col-3 content-center">
						<div class="latest-gigs-price">
							$
							<?=$item["price"]?>
						</div>
						<div class="catname">
							<a href="#"><?=$item["name"] ?> </a>
						</div>
						<div class="rating">						
							<div style="width: 80%;">&nbsp;</div>							
						</div>
					</div>
				</li>
				<?php 
				}
				?>
			</ul>
		</div>
	</div>
</div>
<div class="clearbreak"></div>